<?php
/*留言评论模块*/
class MessageAction extends CommonAction {
	public function index(){
		$this->assign('title','留言列表'.' - '.C('SITE_NAME'));
		$this->display();
	}
	
	//发表留言
	public function add(){
		if($_SESSION['verify']!=md5($_POST['verify'])){
			 echo '<div class="pop">验证码错误，发表失败！</div>';
			 return false;
		}else{
			$data = safe($_POST);
			$data['status'] = C('HOME_SEND_STATUS');
			$data['ip'] = get_client_ip();
			$data['add_time'] = time();
			
			//这个参数是传入的 根据app()函数返回的一些当前页面信息
			if(isset($data['AppParams'])){ 	
				list($data['modelname'], $data['modekeyvalue'], $data['fromurl']) = explode('┆', $data['AppParams']);
				unset($data['AppParams']);
			}
			
			if(D('Message')->add($data)){
				if(C('HOME_SEND_STATUS')){
					echo '<div class="pop">发表成功！</div>';
				}else{
					echo '<div class="pop">发表成功，请等待审核！</div>';
				} 
			}else{
				echo '<div class="pop">发表失败！</div>';
			}
		}
	}
}